import { IPSAppDEDataSet } from '../../app/dataentity/ipsapp-dedata-set';
import { IPSAppDEField } from '../../app/dataentity/ipsapp-defield';
import { IPSAppDataEntity } from '../../app/dataentity/ipsapp-data-entity';
import { IPSCodeList } from '../../codelist/ipscode-list';
import { IPSControlAction } from '../ipscontrol-action';
import { PSMDAjaxControlContainerImpl2 } from '../psmdajax-control-container-impl2';
import { IPSDEGrid } from './ipsdegrid';
import { IPSDEGridColumn } from './ipsdegrid-column';
import { IPSDEGridDataItem } from './ipsdegrid-data-item';
import { IPSDEGridEditItem } from './ipsdegrid-edit-item';
import { IPSDEGridEditItemUpdate } from './ipsdegrid-edit-item-update';
import { IPSDEGridEditItemVR } from './ipsdegrid-edit-item-vr';
import { IPSLayoutPanel } from '../panel/ipslayout-panel';
import { IPSDEField } from '../../dataentity/defield/ipsdefield';
import { IPSLanguageRes } from '../../res/ipslanguage-res';

export class PSDEGridImpl extends PSMDAjaxControlContainerImpl2 implements IPSDEGrid {
  get aggMode(): 'NONE' | 'PAGE' | 'ALL' {
    return this.M.aggMode;
  }

  protected aggpsappdedataset: IPSAppDEDataSet | null = null;

  getAggPSAppDEDataSet(): IPSAppDEDataSet | null {
    if (this.aggpsappdedataset != null) return this.aggpsappdedataset;
    const value = this.M.getAggPSAppDEDataSet;
    if (value == null) {
      return null;
    }
    this.aggpsappdedataset = this.getAggPSAppDataEntityMust().findPSAppDEDataSet(value);
    return this.aggpsappdedataset;
  }

  get aggPSAppDEDataSet(): IPSAppDEDataSet | null {
    return this.getAggPSAppDEDataSet();
  }

  getAggPSAppDEDataSetMust(): IPSAppDEDataSet {
    const value = this.getAggPSAppDEDataSet();
    if (value == null) {
      throw new Error('未指定聚合服务应用实体数据集');
    }
    return value;
  }

  protected aggpsappdataentity: IPSAppDataEntity | null = null;

  getAggPSAppDataEntity(): IPSAppDataEntity | null {
    if (this.aggpsappdataentity != null) return this.aggpsappdataentity;
    const value = this.M.getAggPSAppDataEntity;
    if (value == null) {
      return null;
    }
    this.aggpsappdataentity = this.getPSModel4('app.dataentity.IPSAppDataEntity', value, 'getAggPSAppDataEntity') as IPSAppDataEntity;
    return this.aggpsappdataentity;
  }

  get aggPSAppDataEntity(): IPSAppDataEntity | null {
    return this.getAggPSAppDataEntity();
  }

  getAggPSAppDataEntityMust(): IPSAppDataEntity {
    const value = this.getAggPSAppDataEntity();
    if (value == null) {
      throw new Error('未指定聚合服务应用实体对象');
    }
    return value;
  }

  protected aggpslayoutpanel: IPSLayoutPanel | null = null;

  getAggPSLayoutPanel(): IPSLayoutPanel | null {
    if (this.aggpslayoutpanel != null) return this.aggpslayoutpanel;
    const value = this.M.getAggPSLayoutPanel;
    if (value == null) {
      return null;
    }
    this.aggpslayoutpanel = this.getPSModel4('control.panel.IPSLayoutPanel', value, 'getAggPSLayoutPanel') as IPSLayoutPanel;
    return this.aggpslayoutpanel;
  }

  get aggPSLayoutPanel(): IPSLayoutPanel | null {
    return this.getAggPSLayoutPanel();
  }

  getAggPSLayoutPanelMust(): IPSLayoutPanel {
    const value = this.getAggPSLayoutPanel();
    if (value == null) {
      throw new Error('未指定聚合数据布局面板');
    }
    return value;
  }

  get codeName(): string {
    return this.M.codeName;
  }

  get columnEnableFilter(): 0 | 1 | 2 {
    return this.M.columnEnableFilter;
  }

  get columnEnableLink(): 0 | 1 | 2 {
    return this.M.columnEnableLink;
  }

  protected createpscontrolaction: IPSControlAction | null = null;

  getCreatePSControlAction(): IPSControlAction | null {
    if (this.createpscontrolaction != null) return this.createpscontrolaction;
    const value = this.M.getCreatePSControlAction;
    if (value == null) {
      return null;
    }
    this.createpscontrolaction = this.getPSModel4('control.IPSControlAction', value, 'getCreatePSControlAction') as IPSControlAction;
    return this.createpscontrolaction;
  }

  get createPSControlAction(): IPSControlAction | null {
    return this.getCreatePSControlAction();
  }

  getCreatePSControlActionMust(): IPSControlAction {
    const value = this.getCreatePSControlAction();
    if (value == null) {
      throw new Error('未指定建立数据行为');
    }
    return value;
  }

  get emptyText(): string {
    return this.M.emptyText;
  }

  protected emptytextpslanguageres: IPSLanguageRes | null = null;

  getEmptyTextPSLanguageRes(): IPSLanguageRes | null {
    if (this.emptytextpslanguageres != null) return this.emptytextpslanguageres;
    const value = this.M.getEmptyTextPSLanguageRes;
    if (value == null) {
      return null;
    }
    this.emptytextpslanguageres = this.getPSModel4('res.IPSLanguageRes', value, 'getEmptyTextPSLanguageRes') as IPSLanguageRes;
    return this.emptytextpslanguageres;
  }

  get emptyTextPSLanguageRes(): IPSLanguageRes | null {
    return this.getEmptyTextPSLanguageRes();
  }

  getEmptyTextPSLanguageResMust(): IPSLanguageRes {
    const value = this.getEmptyTextPSLanguageRes();
    if (value == null) {
      throw new Error('未指定无值内容语言资源');
    }
    return value;
  }

  get frozenFirstColumn(): number {
    return this.M.frozenFirstColumn != null ? this.M.frozenFirstColumn : 0;
  }

  get frozenLastColumn(): number {
    return this.M.frozenLastColumn != null ? this.M.frozenLastColumn : 0;
  }

  protected getdraftfrompscontrolaction: IPSControlAction | null = null;

  getGetDraftFromPSControlAction(): IPSControlAction | null {
    if (this.getdraftfrompscontrolaction != null) return this.getdraftfrompscontrolaction;
    const value = this.M.getGetDraftFromPSControlAction;
    if (value == null) {
      return null;
    }
    this.getdraftfrompscontrolaction = this.getPSModel4('control.IPSControlAction', value, 'getGetDraftFromPSControlAction') as IPSControlAction;
    return this.getdraftfrompscontrolaction;
  }

  get getDraftFromPSControlAction(): IPSControlAction | null {
    return this.getGetDraftFromPSControlAction();
  }

  getGetDraftFromPSControlActionMust(): IPSControlAction {
    const value = this.getGetDraftFromPSControlAction();
    if (value == null) {
      throw new Error('未指定获取草稿数据行为（拷贝）');
    }
    return value;
  }

  protected getdraftpscontrolaction: IPSControlAction | null = null;

  getGetDraftPSControlAction(): IPSControlAction | null {
    if (this.getdraftpscontrolaction != null) return this.getdraftpscontrolaction;
    const value = this.M.getGetDraftPSControlAction;
    if (value == null) {
      return null;
    }
    this.getdraftpscontrolaction = this.getPSModel4('control.IPSControlAction', value, 'getGetDraftPSControlAction') as IPSControlAction;
    return this.getdraftpscontrolaction;
  }

  get getDraftPSControlAction(): IPSControlAction | null {
    return this.getGetDraftPSControlAction();
  }

  getGetDraftPSControlActionMust(): IPSControlAction {
    const value = this.getGetDraftPSControlAction();
    if (value == null) {
      throw new Error('未指定获取草稿数据行为');
    }
    return value;
  }

  protected getpscontrolaction: IPSControlAction | null = null;

  getGetPSControlAction(): IPSControlAction | null {
    if (this.getpscontrolaction != null) return this.getpscontrolaction;
    const value = this.M.getGetPSControlAction;
    if (value == null) {
      return null;
    }
    this.getpscontrolaction = this.getPSModel4('control.IPSControlAction', value, 'getGetPSControlAction') as IPSControlAction;
    return this.getpscontrolaction;
  }

  get getPSControlAction(): IPSControlAction | null {
    return this.getGetPSControlAction();
  }

  getGetPSControlActionMust(): IPSControlAction {
    const value = this.getGetPSControlAction();
    if (value == null) {
      throw new Error('未指定获取数据行为');
    }
    return value;
  }

  get gridStyle(): 'TREEGRID' | 'GROUPGRID' | 'LIST' | 'LIST_SORT' | 'USER' | 'USER2' {
    return this.M.gridStyle;
  }

  get groupMode(): 'NONE' | 'AUTO' | 'CODELIST' {
    return this.M.groupMode;
  }

  protected grouppsappdefield: IPSAppDEField | null = null;

  getGroupPSAppDEField(): IPSAppDEField | null {
    if (this.grouppsappdefield != null) return this.grouppsappdefield;
    const value = this.M.getGroupPSAppDEField;
    if (value == null) {
      return null;
    }
    this.grouppsappdefield = this.getPSModel4('app.dataentity.IPSAppDEField', value, 'getGroupPSAppDEField') as IPSAppDEField;
    return this.grouppsappdefield;
  }

  get groupPSAppDEField(): IPSAppDEField | null {
    return this.getGroupPSAppDEField();
  }

  getGroupPSAppDEFieldMust(): IPSAppDEField {
    const value = this.getGroupPSAppDEField();
    if (value == null) {
      throw new Error('未指定分组应用实体属性');
    }
    return value;
  }

  protected grouppscodelist: IPSCodeList | null = null;

  getGroupPSCodeList(): IPSCodeList | null {
    if (this.grouppscodelist != null) return this.grouppscodelist;
    const value = this.M.getGroupPSCodeList;
    if (value == null) {
      return null;
    }
    this.grouppscodelist = this.getPSModel4('codelist.IPSCodeList', value, 'getGroupPSCodeList') as IPSCodeList;
    return this.grouppscodelist;
  }

  get groupPSCodeList(): IPSCodeList | null {
    return this.getGroupPSCodeList();
  }

  getGroupPSCodeListMust(): IPSCodeList {
    const value = this.getGroupPSCodeList();
    if (value == null) {
      throw new Error('未指定分组代码表');
    }
    return value;
  }

  protected grouppsdefield: IPSDEField | null = null;

  getGroupPSDEField(): IPSDEField | null {
    if (this.grouppsdefield != null) return this.grouppsdefield;
    const value = this.M.getGroupPSDEField;
    if (value == null) {
      return null;
    }
    this.grouppsdefield = this.getPSModel4('dataentity.defield.IPSDEField', value, 'getGroupPSDEField') as IPSDEField;
    return this.grouppsdefield;
  }

  get groupPSDEField(): IPSDEField | null {
    return this.getGroupPSDEField();
  }

  getGroupPSDEFieldMust(): IPSDEField {
    const value = this.getGroupPSDEField();
    if (value == null) {
      throw new Error('未指定分组实体属性');
    }
    return value;
  }

  get minorSortDir(): 'ASC' | 'DESC' {
    return this.M.minorSortDir;
  }

  protected minorsortpsappdefield: IPSAppDEField | null = null;

  getMinorSortPSAppDEField(): IPSAppDEField | null {
    if (this.minorsortpsappdefield != null) return this.minorsortpsappdefield;
    const value = this.M.getMinorSortPSAppDEField;
    if (value == null) {
      return null;
    }
    this.minorsortpsappdefield = this.getPSModel4('app.dataentity.IPSAppDEField', value, 'getMinorSortPSAppDEField') as IPSAppDEField;
    return this.minorsortpsappdefield;
  }

  get minorSortPSAppDEField(): IPSAppDEField | null {
    return this.getMinorSortPSAppDEField();
  }

  getMinorSortPSAppDEFieldMust(): IPSAppDEField {
    const value = this.getMinorSortPSAppDEField();
    if (value == null) {
      throw new Error('未指定附加排序应用实体属性');
    }
    return value;
  }

  protected ordervaluepsappdefield: IPSAppDEField | null = null;

  getOrderValuePSAppDEField(): IPSAppDEField | null {
    if (this.ordervaluepsappdefield != null) return this.ordervaluepsappdefield;
    const value = this.M.getOrderValuePSAppDEField;
    if (value == null) {
      return null;
    }
    this.ordervaluepsappdefield = this.getPSModel4('app.dataentity.IPSAppDEField', value, 'getOrderValuePSAppDEField') as IPSAppDEField;
    return this.ordervaluepsappdefield;
  }

  get orderValuePSAppDEField(): IPSAppDEField | null {
    return this.getOrderValuePSAppDEField();
  }

  getOrderValuePSAppDEFieldMust(): IPSAppDEField {
    const value = this.getOrderValuePSAppDEField();
    if (value == null) {
      throw new Error('未指定排序值应用实体属性');
    }
    return value;
  }

  protected psdegridcolumns: IPSDEGridColumn[] | null = null;

  getPSDEGridColumns(): IPSDEGridColumn[] | null {
    if (this.psdegridcolumns == null) {
      this.psdegridcolumns = this.fillChildListModel(this.M.getPSDEGridColumns, 'control.grid.IPSDEGridColumn') as IPSDEGridColumn[];
    }
    return this.psdegridcolumns;
  }

  get psDEGridColumns(): IPSDEGridColumn[] | null {
    return this.getPSDEGridColumns();
  }

  findPSDEGridColumn(objKey: any): IPSDEGridColumn | null {
    return this.getPSModel5('control.grid.IPSDEGridColumn', this.getPSDEGridColumns(), objKey) as IPSDEGridColumn;
  }

  protected psdegriddataitems: IPSDEGridDataItem[] | null = null;

  getPSDEGridDataItems(): IPSDEGridDataItem[] | null {
    if (this.psdegriddataitems == null) {
      this.psdegriddataitems = this.fillChildListModel(this.M.getPSDEGridDataItems, 'control.grid.IPSDEGridDataItem') as IPSDEGridDataItem[];
    }
    return this.psdegriddataitems;
  }

  get psDEGridDataItems(): IPSDEGridDataItem[] | null {
    return this.getPSDEGridDataItems();
  }

  findPSDEGridDataItem(objKey: any): IPSDEGridDataItem | null {
    return this.getPSModel5('control.grid.IPSDEGridDataItem', this.getPSDEGridDataItems(), objKey) as IPSDEGridDataItem;
  }

  protected psdegridedititemupdates: IPSDEGridEditItemUpdate[] | null = null;

  getPSDEGridEditItemUpdates(): IPSDEGridEditItemUpdate[] | null {
    if (this.psdegridedititemupdates == null) {
      this.psdegridedititemupdates = this.fillChildListModel(this.M.getPSDEGridEditItemUpdates, 'control.grid.IPSDEGridEditItemUpdate') as IPSDEGridEditItemUpdate[];
    }
    return this.psdegridedititemupdates;
  }

  get psDEGridEditItemUpdates(): IPSDEGridEditItemUpdate[] | null {
    return this.getPSDEGridEditItemUpdates();
  }

  findPSDEGridEditItemUpdate(objKey: any): IPSDEGridEditItemUpdate | null {
    return this.getPSModel5('control.grid.IPSDEGridEditItemUpdate', this.getPSDEGridEditItemUpdates(), objKey) as IPSDEGridEditItemUpdate;
  }

  protected psdegridedititemvrs: IPSDEGridEditItemVR[] | null = null;

  getPSDEGridEditItemVRs(): IPSDEGridEditItemVR[] | null {
    if (this.psdegridedititemvrs == null) {
      this.psdegridedititemvrs = this.fillChildListModel(this.M.getPSDEGridEditItemVRs, 'control.grid.IPSDEGridEditItemVR') as IPSDEGridEditItemVR[];
    }
    return this.psdegridedititemvrs;
  }

  get psDEGridEditItemVRs(): IPSDEGridEditItemVR[] | null {
    return this.getPSDEGridEditItemVRs();
  }

  findPSDEGridEditItemVR(objKey: any): IPSDEGridEditItemVR | null {
    return this.getPSModel5('control.grid.IPSDEGridEditItemVR', this.getPSDEGridEditItemVRs(), objKey) as IPSDEGridEditItemVR;
  }

  protected psdegridedititems: IPSDEGridEditItem[] | null = null;

  getPSDEGridEditItems(): IPSDEGridEditItem[] | null {
    if (this.psdegridedititems == null) {
      this.psdegridedititems = this.fillChildListModel(this.M.getPSDEGridEditItems, 'control.grid.IPSDEGridEditItem') as IPSDEGridEditItem[];
    }
    return this.psdegridedititems;
  }

  get psDEGridEditItems(): IPSDEGridEditItem[] | null {
    return this.getPSDEGridEditItems();
  }

  findPSDEGridEditItem(objKey: any): IPSDEGridEditItem | null {
    return this.getPSModel5('control.grid.IPSDEGridEditItem', this.getPSDEGridEditItems(), objKey) as IPSDEGridEditItem;
  }

  get pagingSize(): number {
    return this.M.pagingSize;
  }

  protected removepscontrolaction: IPSControlAction | null = null;

  getRemovePSControlAction(): IPSControlAction | null {
    if (this.removepscontrolaction != null) return this.removepscontrolaction;
    const value = this.M.getRemovePSControlAction;
    if (value == null) {
      return null;
    }
    this.removepscontrolaction = this.getPSModel4('control.IPSControlAction', value, 'getRemovePSControlAction') as IPSControlAction;
    return this.removepscontrolaction;
  }

  get removePSControlAction(): IPSControlAction | null {
    return this.getRemovePSControlAction();
  }

  getRemovePSControlActionMust(): IPSControlAction {
    const value = this.getRemovePSControlAction();
    if (value == null) {
      throw new Error('未指定删除数据行为');
    }
    return value;
  }

  get sortMode(): 'REMOTE' | 'LOCAL' {
    return this.M.sortMode;
  }

  protected updatepscontrolaction: IPSControlAction | null = null;

  getUpdatePSControlAction(): IPSControlAction | null {
    if (this.updatepscontrolaction != null) return this.updatepscontrolaction;
    const value = this.M.getUpdatePSControlAction;
    if (value == null) {
      return null;
    }
    this.updatepscontrolaction = this.getPSModel4('control.IPSControlAction', value, 'getUpdatePSControlAction') as IPSControlAction;
    return this.updatepscontrolaction;
  }

  get updatePSControlAction(): IPSControlAction | null {
    return this.getUpdatePSControlAction();
  }

  getUpdatePSControlActionMust(): IPSControlAction {
    const value = this.getUpdatePSControlAction();
    if (value == null) {
      throw new Error('未指定更新数据行为');
    }
    return value;
  }

  get hasWFDataItems(): boolean {
    return this.M.hasWFDataItems;
  }

  getHasWFDataItems(): boolean {
    return this.M.hasWFDataItems;
  }

  get enableColFilter(): boolean {
    return this.M.enableColFilter;
  }

  get enableCustomized(): boolean {
    return this.M.enableCustomized;
  }

  get enableGroup(): boolean {
    return this.M.enableGroup;
  }

  get enablePagingBar(): boolean {
    return this.M.enablePagingBar;
  }

  get enableRowEdit(): boolean {
    return this.M.enableRowEdit;
  }

  get enableRowEditOrder(): boolean {
    return this.M.enableRowEditOrder;
  }

  get enableRowNew(): boolean {
    return this.M.enableRowNew;
  }

  get forceFit(): boolean {
    return this.M.forceFit;
  }

  get hideHeader(): boolean {
    return this.M.hideHeader;
  }

  get noSort(): boolean {
    return this.M.noSort;
  }

  get singleSelect(): boolean {
    return this.M.singleSelect;
  }

  get cls(): string {
    return 'PSDEGridImpl';
  }

  instanceof(cls: string): boolean {
    if (
      cls == 'IPSModelObject' ||
      cls == 'IPSObject' ||
      cls == 'control.IPSAjaxControl' ||
      cls == 'control.IPSControl' ||
      cls == 'control.IPSControlContainer' ||
      cls == 'control.IPSControlNavigatable' ||
      cls == 'control.IPSMDAjaxControl' ||
      cls == 'control.IPSMDControl' ||
      cls == 'control.IPSMDControl2' ||
      cls == 'control.grid.IPSDEGrid'
    )
      return true;
    return super.instanceof(cls);
  }
}
